<!DOCTYPE html>
<html lang="en">
<head>
    <meta  http-equiv="content-type" content="text/html" charset="utf-8"/>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" charset="UTF-8" src="test.js" ></script>
    <script type="text/javascript">
        var arr=[1,2,3,4,5,4,3,2,1];
        var result =arr.every(function(item,index,arr){
            return item>0;
        });
        var result1 =arr.filter(function(item,index,arr){
            return item>2;
        });
        var result2 =arr.forEach(function(item,index,arr){
            alert(item);
        });

        var result3 =arr.map(function(item,index,arr){
            return item*2;
        });

        var result4 =arr.some(function(item,index,arr){
            return item>10;
        });

        /**
         * 从左边开始遍历
         * prev:前一个值
         * cur:当前值
         * index:当前索引
         * arr：当前数组
         * @type {*}
         */
        var result5 =arr.reduce(function(prev,cur,index,arr){
            return prev+cur;
        });
        /**
         * 从右边开始遍历
         * @type {*}
         */
        var result6 =arr.reduceRight(function(prev,cur,index,arr){
            return prev+cur;
        });

        alert(result5);

    </script>
</head>
<body>

</body>
</html>